Replace Trigger?

Hi,

I'm trying to develop a little utility for myself to work with triggers. One feature I have is that when a user selects a trigger from a list in a GUI, the dxl for that trigger shows in one read-only frame, and a writeable frame below it can be used to draft new dxl. The idea is that when the user selects an "Update" button, the callback function replaces code of the selected trigger with whatever the user has typed. I cannot seem to get this to work. I'm trying to create a new trigger with all the same characteristics as the old trigger, then deleting the old one. I think the problem has to do with creating a trigger with the same name as an existing trigger; I am not sure DOORS handles that well (maybe it shouldn't). The relevant code snippet is below. SkTriggers is my createString() skip list, tNameDBE is my DBE list of trigger names, codeFrame is the read-only, newDXLFrame is the writeable. There's some debug code in there too.

This would all be easier if I could just save off the full values of level, scope, event, and type, but the DXL manual doesn't tell me what type those variables are

Thanks in advance for any help.

   string sTName = get (tNameDBE);
   Trigger trgToReplace;
   if (find(skTriggers, sTName, trgToReplace)) {
    Trigger newTrigger;
    if (level(trgToReplace) == module){
     newTrigger = trigger(name(trgToReplace), module->(scope(trgToReplace) ""), type(trgToReplace), event(trgToReplace), priority(trgToReplace), newDXL);
    }
    else if (level(trgToReplace) == object) {
     newTrigger = trigger(name(trgToReplace), module->object->(scope(trgToReplace) ""), type(trgToReplace), event(trgToReplace), priority(trgToReplace), newDXL);
    }
    else if (level(trgToReplace) == attribute) {
     newTrigger = trigger(name(trgToReplace), module->object->all->attribute->(attribute(trgToReplace) ""), type(trgToReplace), event(trgToReplace), priority(trgToReplace), newDXL);
    }
    else {
     ack("Other");
    }
    delete(trgToReplace);
    print name(trgToReplace) "\n";
    print newDXL "\n";
    print dxl(trgToReplace) "\n";
    print "**\n";
    set(codeFrame, dxl(newTrigger));
    set(newDXLFrame, "");
    refreshTriggerList();

 


SD_John - Wed Jun 10 11:21:39 EDT 2015

Re: Replace Trigger?
O.Wilkop - Wed Jun 10 14:47:56 EDT 2015

Hey

the possible trigger functions have the following signature:

 

Trigger trigger (trigLevel_ l, trigEvent_ e, int p, bool pre(Trigger))
Trigger trigger (string name, trigLevel_ l, trigType_ t, trigEvent_ e, int p, string dxl)
Trigger trigger (trigLevelDesc_ d, trigEvent_ e, int p, void post(Trigger))
Trigger trigger (string name, trigLevelDesc_ d, trigType_ t, trigEvent_ e, int p, string dxl)
Trigger trigger (trigLevelDesc_ d, trigEvent_ e, int p, bool pre(Trigger))
Trigger trigger (trigLevel_ l, trigEvent_ e, int p, void post(Trigger))

 

You just gotta see which one of those you are using (probably one of the two with the dxl string  variable at the end)

Re: Replace Trigger?
SD_John - Wed Jun 10 15:41:24 EDT 2015

O.Wilkop - Wed Jun 10 14:47:56 EDT 2015

Hey

the possible trigger functions have the following signature:

 

Trigger trigger (trigLevel_ l, trigEvent_ e, int p, bool pre(Trigger))
Trigger trigger (string name, trigLevel_ l, trigType_ t, trigEvent_ e, int p, string dxl)
Trigger trigger (trigLevelDesc_ d, trigEvent_ e, int p, void post(Trigger))
Trigger trigger (string name, trigLevelDesc_ d, trigType_ t, trigEvent_ e, int p, string dxl)
Trigger trigger (trigLevelDesc_ d, trigEvent_ e, int p, bool pre(Trigger))
Trigger trigger (trigLevel_ l, trigEvent_ e, int p, void post(Trigger))

 

You just gotta see which one of those you are using (probably one of the two with the dxl string  variable at the end)

Brilliant, thank you! Where did you get that information about the trigger() signatures? It's not in the DXL Manual.

 

For future reference, the functional version of that snippet is:

                        string sTName = get (tNameDBE);
                        Trigger trgToReplace;
                        if (find(skTriggers, sTName, trgToReplace)) {
                                trigType_ ttrType = type(trgToReplace);
                                trigEvent_ ttrEvent = event(trgToReplace);
                                int ttrPriority = priority(trgToReplace);
                                trigLevelDesc_ ttrLevelDesc;
                                if (level(trgToReplace) == module){
                                         ttrLevelDesc = module->(scope(trgToReplace) "");
                                }
                                else if (level(trgToReplace) == object) {
                                        ttrLevelDesc = module->object->(scope(trgToReplace) "");
                                }
                                else if (level(trgToReplace) == attribute) {
                                        ttrLevelDesc = module->object->all->attribute->(attribute(trgToReplace) "");
                                }
                                else {
                                        ack("Other");
                                }
                                delete(trgToReplace);
                                Trigger newTrigger = trigger(sTName, ttrLevelDesc, ttrType, ttrEvent, ttrPriority, newDXL);
                                set(codeFrame, dxl(newTrigger));
                                set(newDXLFrame, "");
                                refreshTriggerList();
                        }

 

Re: Replace Trigger?
O.Wilkop - Wed Jun 10 18:06:05 EDT 2015

I took the signatures from the dxl perms found here:

https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014580797